<template lang="html">
  <div class="box">
      <div class="body">
          <el-table :data="tableData.list" style="width: 100%">
              <el-table-column label="市代名称" prop="company" align="center" width=""></el-table-column>
              <el-table-column label="地区" align="center" width="">
                <template slot-scope="scope">
                  <p v-for="i,k in scope.row.area" :key="k">{{i.name}}</p>
                </template>
              </el-table-column>
              <el-table-column label="联系电话" prop="phone" align="center" width=""></el-table-column>
              <el-table-column label="负责人" prop="leader" align="center" width=""></el-table-column>
              <el-table-column label="申请时间" prop="create_time" align="center" width=""></el-table-column>
              <el-table-column label="取消理由" align="center" width="">
                <template slot-scope="scope">
                  <el-popover  placement="top"  trigger="hover">
                    <p>{{scope.row.reason}}</p>
                    <el-button slot="reference" type="primary" size="mini" plain>查看理由</el-button>
                  </el-popover>
                </template>
              </el-table-column>
              <el-table-column label="物料交接" align="center" width="">
                <template slot-scope="scope">
                  <el-button @click="onshow(scope.row)" type="primary" size="mini" plain>查看详情</el-button>
                </template>
              </el-table-column>
              <el-table-column label="通过时间" prop="audit_time" align="center" width=""></el-table-column>
          </el-table>
      </div>
      <div class="page_box">
          <el-pagination class="page" layout="prev, pager, next"
            @current-change="switchPage" :page-count='tableData.rows' >
          </el-pagination>
      </div>

      <el-dialog title="物料交接" :visible.sync="dialogTableVisible">
        <el-table :data="gridData">
          <el-table-column property="name" align="center" label="物料名称"></el-table-column>
          <el-table-column property="ration" align="center" label="原有期初配给"></el-table-column>
          <el-table-column property="materiel_stock" align="center" label="原剩余库存"></el-table-column>
          <el-table-column property="supplement" align="center" label="补充数量"></el-table-column>
        </el-table>
      </el-dialog>
  </div>
</template>

<script>
export default{
  data(){
    return {
      tableData:[],
      gridData: [],
      dialogTableVisible:false
    }
  },
  created(){
    this.cancelList()
  },
  methods:{
    cancelList(page = 1){
      this.$http3.cancelList({page}).
      then(res=>{
        this.tableData =
        res.data.code == 1?
        res.data.data:[]
      })
    },
    switchPage(p){
      this.cancelList(p)
    },
    onshow(e){
      this.gridData = [];
      this.dialogTableVisible = true;
      this.$http3.getMateDetail({
        id: e.id
      }).then(res=>{
        this.gridData =
        res.data.code == 1?
        res.data.data:[]
      })
    },

  }
}
</script>

<style lang="css" scoped>
@import "../../my-style/app.css";

/deep/ .el-input-group__append, .el-input-group__prepend{
  background-color: #3498E9;
  border: none;
  color: white;
}

.preview-img{
  display: block;
  width: 100%;
  height: 30px;
}
.header{
  margin-bottom: 10px
}
.page_box{
  text-align: center;
}
</style>
